#ifndef DEVICEFAILUREINFO_H
#define DEVICEFAILUREINFO_H

#include <QWidget>
#include <QTimer>


namespace Hydra_DeviceFailureInfo {

typedef enum _device_failure_info
{
    INIT,                                   // 初始态
    RADIO_FAILURE,                          // 无线故障
    ATP_FAILURE,                            // ATP故障
    ATO_FAILURE                             // ATO故障
}DEVICE_FAILURE_INFO;

}

using namespace Hydra_DeviceFailureInfo;

class DeviceFailureInfo : public QWidget
{
    Q_OBJECT

public:
    DeviceFailureInfo(QWidget *parent = 0);

    void setInterval(quint16 interval);
    void setState(DEVICE_FAILURE_INFO state);
    void setTextFontFace(QString name);
    void setRADIOText(QString str);
    void setATPText(QString str);
    void setATOText(QString str);
    void setTextColor(QColor color);
    void setRectColor(QColor color);
    void setRectLineWidth(quint8 width);
    void setImageHeightProportion(quint8 value);


public slots:
    void refresh();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);
    void initParam();
    void drawImage(QPainter *pPainter);
    void drawText(QPainter *pPainter);
    void drawOutsideRect(QPainter *pPainter);



private:
    QTimer mTimer;
    QPoint mCenterPoint;
    quint8 mImageHeightProportion = 80;
    DEVICE_FAILURE_INFO mState = DEVICE_FAILURE_INFO::INIT;
    QColor mTextColor = QColor(212, 212, 212);
    QColor mRectColor = QColor(189, 0, 0);
    QString mTextFontFace = "Arial";
    QRect mOutsideRect;
    quint8 mOutsideRectLineWidth = 4;
    QRect mTextRect;
    QString mStrRADIO = "RAD";
    QString mStrATP = "ATP";
    QString mStrATO = "ATO";

};

#endif // DEVICEFAILUREINFO_H
